<?php

namespace app\common\model\user;

use app\common\enum\user\UserCashPayTypeEnum;
use app\common\enum\user\UserCashStatusEnum;
use app\common\model\BaseModel;

class UserCash extends BaseModel
{
    protected $name = 'user_cash';
    protected $autoWriteTimestamp = true;

    public function getPayTypeAttr($value, $data)
    {
        $list = UserCashPayTypeEnum::data();
        return ['value' => $value, 'text' => $list[$value]['name']];
    }

    public function getApplyStatusAttr($value, $data)
    {
        $list = UserCashStatusEnum::data();
        return ['value' => $value, 'text' => $list[$value]['name']];
    }

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'user_id');
    }
}